<div id="panel-button" class="row">
	<div class="col-md-12">
		<div class="panel panel-default">
			<div class="panel-body text-right">
				<div class="col-sm-4 pull-left">
					{{Form::text('filter', null, array('id' => 'filter', 'class' => 'form-control', 'placeholder' => trans('form.filter')))}}
				</div>
				{{Form::button(trans('form.create'), array('class' => 'btn btn-success', 'id' => 'create'))}}
			</div>
		</div>
	</div>
</div>

<div id="panel-button-fixed" class="row hidden">
	<div class="col-md-12">
		<div class="panel panel-default">
			<div class="panel-body text-right">
				<div class="col-sm-4 pull-left">
					{{Form::text('filter', null, array('id' => 'filter', 'class' => 'form-control', 'placeholder' => trans('form.filter')))}}
				</div>
				{{Form::button(trans('form.create'), array('class' => 'btn btn-success', 'id' => 'create'))}}
			</div>
		</div>
	</div>
</div>

@if(Session::has('error'))
	<div id="panel-error" class="row hidden">
		<div class="col-md-12">
			<div class="panel panel-red panel-minimal">
				<header class="panel-heading">{{trans('form.form_error')}}</header>
				<div id="error-content" class="panel-body">
					{{Session::get('message', 'Something is error!')}}
				</div>
			</div>
		</div>
	</div>
@endif
<div class="row">
	<div class="col-md-12">
		<div class="panel panel-default">
			<!--<header class="panel-heading">{{trans('brand.brand_list')}}</header>-->
			<div class="panel-body">
				<div class="table-responsive">
					<table class="table table-striped footable" data-filter="#filter" data-page-size="10" data-filter-minimum="1">
						<thead>
							<tr>
								<th>{{trans('brand.brand')}}</th>
								<th data-sort-initial="true" data-type="numeric">{{trans('brand.order')}}</th>
								<th data-type="date">{{trans('brand.created_at')}}</th>
								<th>{{trans('brand.updated_at')}}</th>
								<th>{{trans('form.tool')}}</th>
							</tr>
						</thead>
						<tbody>
							@foreach($brands as $row)
							<tr id="taxonomy" data-id="{{$row->id}}">
								<td>{{HTML::link('admin/brand/edit/' . $row->id, $row->taxonomy)}}</td>
								<td>{{$row->order}}</td>
								<td>{{date("d-m-Y H:i:s", strtotime($row->created_at))}}</td>
								<td>{{date("d-m-Y H:i:s", strtotime($row->updated_at))}}</td>
								<td>
									{{Form::button(trans('form.delete'), array('class' => 'btn btn-mini btn-danger', 'id' => 'delete', 'data-id' => $row->id, 'data-taxonomy' => $row->taxonomy))}}
								</td>
							</tr>
							@endforeach
						</tbody>
						<tfoot>
							<tr>
								<td colspan="5">
									<ul class="pagination pagination-sm"></ul>
								</td>
							</tr>
						</tfoot>
					</table>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
	$("tr#taxonomy").click(function(){
		var id = $(this).attr('data-id');
		var url = '{{URL::to("admin/brand/edit")}}' + "/" + id;

		window.location = url;
	});

	$("button#delete").click(function() {
		var taxonomy = $(this).attr('data-taxonomy');
		var ok = confirm("{{trans('brand.confirm_delete')}}" + taxonomy + "?");

		if(ok){
			var id = $(this).attr('data-id');

			$.ajax({
				url: '{{URL::to("admin/brand/delete")}}',
				type: 'POST',
				data: {'id': id},
				success: function(result){
					window.location.reload();
				}
			});
		}

		return false;
	});

	$("button#create").click(function(){
		var url = "{{URL::to('admin/brand/create')}}";

		window.location = url;
	});

	$('.footable').footable();
});
</script>